package com.tuanbiao.models.action;

import androidx.annotation.NonNull;

import com.hzjq.data.callback.HttpCallback;
import com.hzjq.data.hzjq.entity.DeviceInfoEntity;
import com.hzjq.lib.BlastKool;
import com.hzjq.lib.loader.QuickKool;
import com.tuanbiao.data.callback.OnBaseResultCallback;

/**
 * @author abiao
 * @since 2022/4/25 14:21
 */
public interface DeviceInfoAction {
    default void getDeviceInfo(OnBaseResultCallback<DeviceInfoEntity> callback) {
        QuickKool.Companion.getKool().getDeviceInfo(new HttpCallback<DeviceInfoEntity>() {
            @Override
            public void onSuccess(DeviceInfoEntity entity) {
                callback.onSuccess(entity);
                callback.onFinish();
            }

            @Override
            public void onFailed(@NonNull String s) {
                callback.onFailed(s);
                callback.onFinish();
            }
        });
    }

    default void updateDeviceInfo(boolean enable, DeviceInfoEntity entity, OnBaseResultCallback<Void> callback) {
        QuickKool.Companion.getKool().updateDeviceInfo(enable, entity, () -> {
            callback.onSuccess(null);
            callback.onFinish();
        });
    }

    default void updateDeviceInfo(DeviceInfoEntity entity, OnBaseResultCallback<Void> callback) {
        QuickKool.Companion.getKool().updateDeviceInfo(entity, () -> {
            callback.onSuccess(null);
            callback.onFinish();
        });
    }

    default void uploadDeviceInfo(OnBaseResultCallback<Boolean> callback) {
        BlastKool.Companion.loader().http().uploadDeviceInfo(new HttpCallback<Boolean>() {
            @Override
            public void onSuccess(Boolean aBoolean) {
                callback.onSuccess(aBoolean);
                callback.onFinish();
            }

            @Override
            public void onFailed(@NonNull String s) {
                callback.onFailed(s);
                callback.onFinish();
            }
        });
    }

    @Deprecated
    default void setIMEI(String IMEI) {
        BlastKool.Companion.loader().setImei(IMEI);
    }

    @Deprecated
    default void setMac(String mac) {
        BlastKool.Companion.loader().setMac(mac);
    }

    @Deprecated
    default void setMacAndIMEI(String mac, String IMEI) {
        BlastKool.Companion.loader().setMacImei(mac, IMEI);
    }
}
